/*
    Linear Programming Library
    
    Created by Team Paragon (Shena Hoffmann, Arthur Powalka, Nasir Kenarangui)
    CSCE 689
    
    Karmarkar.h
    Declares the variables and functions used for providing functionality related to the Karmarkar linear programming algorithm
*/

#ifndef Karmarkar_H //ensure that Karmarkar is only included once
#define Karmarkar_H

#include <iostream>
#include <algorithm>
#include <math.h>
#include <tuple>
#include <armadillo>
#include "LinProg.h"

using namespace arma;

class Karmarkar : public LinProg
{
private:
    // ............ PRIVATE CLASS VARIABLES ............ //
    mat objectiveC;
    mat constraintsA;
    mat valuesB;
    double varBound; //(# of primal variables + #of dual variables + # of slack + # of excess)*upperBound

    // ............ HELPER FUNCTIONS ............ //
    mat improvement(mat &x_k, mat &c, mat &A, mat &e);
    double findUpperBound();
    bool isFeasible(const mat &solutionMatrix);		
    void setClassVariables(LinProg &obj);

    
public:
    // ............ CONSTRUCTORS ............ //
    Karmarkar();
    Karmarkar(const LinProg &lp);
    Karmarkar(const Karmarkar& kar);
    Karmarkar(bool max, vector<double> objective, vector<vector<double>> constraints, vector<string> inequalitySigns, vector<double> inequalityVals, vector<bool> constrainedVars);
    
    // ............ DESTRUCTOR ............ //
    ~Karmarkar();	
    
    // ............ FUNCTIONS FOR THE USER ............ //
    tuple<vector<double>, string, double> solve();
    Karmarkar karForm(mat C, mat A, mat b); //use this to access variables and set ObjectiveC and constraintsA
    mat getObjectiveC();
    mat getConstraintsA();
    mat getValuesB();
    
    // ............ OVERLOADED OPERATORS ............ //
    Karmarkar operator=(const Karmarkar &nKar);
};
#endif
